<!DOCTYPE html>
<html ng-app='mysecapp'>
	<head>
		<meta charset="UTF-8">
		<title>手机验证登录</title>
		<link rel="stylesheet" type="text/css" href="../css/reset.css"/>
		<link rel="stylesheet" type="text/css" href="../css/t-login.css"/>
		<link rel="stylesheet" type="text/css" href="../css/nava.css"/>
		<link rel="stylesheet" type="text/css" href="../css/foot.css"/>
		<script type="text/javascript" src="../js/angular.min.js"></script>
		<script type="text/javascript" src="../js/angular-route.min.js"></script>
		<script type="text/javascript" src="../js/jquery-2.2.4.min.js"></script>
	</head>
	<body>
		<div ng-include="'nava.html'"></div>
		<!--头-->
		<div class="logo-out">
			<div>
				<img src="../img/t-logo.png"/>
				<p>会员登录</p>
			</div>
		</div>
		<!--背景登录-->
		<div class="bg-content">
			<div class="login-div clearfix">
				<!--免费注册-->
				<div class="border-out">
					<div>
						<p>礼拜五会员</p>
						<p>免费注册</p>
					</div>
				</div>
				<div class="load-right">
					<div class="doad-div clearfix">
						<span>登录</span>
						<a href="t-loadimg.html">账号密码登录<img src="../img/t-ponson.png" alt=""/></a>
					</div>
					<div class="load-ph">
						<input type="text" id="t-loadtext" placeholder="请输入手机号" />
						<img class="t-loadimg" src="../img/t-phone-true.png" alt=""/>
						<div class="load-wrong">
							<img src="../img/t-wrong-phone.png" alt=""/>
							<span>手机号码不正确，请重新输入</span>
						</div>
					</div>
					<!--<input type="password" id="loadpasw" placeholder="密码" />-->
					<div class="yanzheng1"><input type="text"  class="inputnum1" placeholder="验证码"/><div class="yanimg"></div><span class="spanbtn">看不清换一张</span></div>
					<div class="t-resetnum">
						<input class="phonethr" type="text"  placeholder="手机验证码" /><span class="resetgetnum">获取验证码</span>
					</div>
					<div class="checkDiv">
						<input type="checkbox" id="loadcheck" value="" />
						<span>&nbsp;自动登录</span>
						<a href="t-resetpasword.html">忘记密码?</a>
					</div>
					<div class="lo-div clearfix">
						<span class="loadbtn1">登录</span>
						<span class="loadbtn2">用户注册</span>
					</div>
					<span class="t-notice">提示：未注册用户将直接注册为礼拜五用户</span>
					<p><span>---------------</span>用合作网站登录<span>---------------</span></p>
					<a href="###"><img src="../img/t-load-weixin.png" alt=""/></a>
					<a href="###"><img src="../img/t-load-QQ.png" alt="" /></a>
				</div>
				
			</div>
		</div>
		<div ng-include="'foot.html'"></div>	
	</body>
	<script type="text/javascript">
		var app = angular.module('mysecapp',['ngRoute']);
		var bubu = false;
		app.controller('navctrl',function($scope){
				
				//我的订单
			$('.ding1').click(function(){
				if (bubu) {
					window.location='personalcenter.html#/buy';
				}else{
					window.location='t-loadimg.html';
				};
				
			});
			//我的消息
			$('.ding2').click(function(){
				if (bubu) {
					window.location='personalcenter.html#/msg';
				}else{
					window.location='t-loadimg.html';
				};
				
			});	
			//我的商家
			$('.ding3').click(function(){
				if (bubu) {
					window.location='personalcenter.html#/store';
				}else{
					window.location='t-loadimg.html';
				};
				
			});
			$('.pleaselogin').html(localStorage.getItem("name"));
				$('.t-tui').click(function(){
					if (bubu){
						$('.pleaselogin').html('');
						$(this).html('请登录');
						bubu = false;
					}else{
						$(this).html('退出');
						window.location='t-phoneload.html';
						localStorage.clear()
						
						bubu = true;
					}	
				})
			})
		
		
		var yanimg = document.getElementsByClassName('yanimg')
		var arr = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 
            'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
            'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
        var arr1 = []
		var donum;
		var deg;
		
		var arr2 =[];
//		var obj ={}
		var a='';
		var b='';
		
		var phone = document.getElementById('t-loadtext');
				//手机验证码
				$('.resetgetnum').click(function(){
					for (var i = 0;i<6;i++) {
						b+=Math.floor(Math.random()*9)
						if (/^1[34578]\d{9}$/.test($('#t-loadtext').val())) {
							$('.phonethr').val(b)
						}else(
							 $('.load-wrong').css({
					         	display:'block'
					         })
						)
						
					}
					b=''
				})
		
		//验证码
		for (var i = 0;i<4;i++) {
				deg = Math.floor(Math.random()*100-40);
				donum = Math.floor(Math.random()*62);
				arr1.push(arr[donum]) 
				yanimg[0].innerHTML+= "<span>"+arr1[i]+"</span>"
				$('.yanimg span').eq(i).css({
					transform:'rotateZ('+deg+'deg)'
				})
				a+=arr1[i]
				
		}
		arr1=[];
		$('.spanbtn').click(function(){
			a='';
			$('.yanimg').children('span').remove()
			for (var i = 0;i<4;i++) {
				deg = Math.floor(Math.random()*100-40);
				donum = Math.floor(Math.random()*62);
				arr1.push(arr[donum]) 
				yanimg[0].innerHTML+= "<span>"+arr1[i]+"</span>";
				$('.yanimg span').eq(i).css({
					transform:'rotateZ('+deg+'deg)'
				})
				a+=arr1[i]
			}
			console.log(a)
			arr1=[];
		})
		
		phone.oninput = function(){
			 $('.load-wrong').css({
		         	display:'none'
		         })
			 if(/^1[34578]\d{9}$/.test($('#t-loadtext').val())){
		    		$('.t-loadimg').css({
		    			display:'block'
		    		})
		    	}else{
		    		$('.t-loadimg').css({
		    			display:'none'
		    		})
		    	}
		}
		
		$('.loadbtn1').click(function(){
			
			
			 if(!(/^1[34578]\d{9}$/.test($('#t-loadtext').val()))){ 
		         $('.load-wrong').css({
		         	display:'block'
		         })
		        return false;
			 
		    }else if($('.inputnum1').val()!=a){
		    		alert('验证码输入错误');
		    }else if ($('.phonethr').val()=='') {
		    		alert('手机验证码为空');
		    		 return false;
		    }else{
		    		var obj = {};
			    var phone = $('#t-loadtext').val();
			    var psw = $('#loadpasw').val();
				obj.phone = phone;
//				obj.psw = psw;
				$.post('../php/data3.php',obj,function(data){
					if(data=='登录成功'){
						$('.t-tui').html('退出');
							localStorage.setItem('name',phone);
							localStorage.setItem('pss',psw);
							bubu = true;
					
					    		alert(1);

//						window.location.href='firstPage.html';
					}else{

					    		alert('此账号未被注册')

						
					}
				})
		    }
		  })
		$('.logo-out div img').click(function(){
			window.location.href='firstPage.html';
		})
		$('.logo-out div img').click(function(){
			window.location.href='index.html';
		})
	</script>
</html>

